package com.zyh.generic;

import java.util.Arrays;

/**
 * @Author zyh
 * @Date 2024/7/31 13:59
 * @Description
 */

public class GenericDemo4 {
    public static void main(String[] args) {
        Integer[] arr1={2,5,1,6,8};
        Double[] arr2={1.3,2.5,3.6,4.8,6.6};
        String[] arr3={"2","1","3","4","5"};
        reverse1(arr1);
        reverse1(arr2);
        reverse1(arr3);
    }


    //数组反转
    public static <T> void reverse1(T[] arr){
        for (int start=0,end=arr.length-1;start<=end;start++,end--){
            T temp=arr[start];
            arr[start]=arr[end];
            arr[end]=temp;
        }
        System.out.println(Arrays.toString(arr));
    }
}
